const { notEmpty } = require("../utils.js");

module.exports = {
	description: "generate service",
	prompts: [
		{
			type: "input",
			name: "name",
			message: "service name please",
			validate: notEmpty("name")
		},
		{
			type: "input",
			name: "group",
			message: '@Service("group")'
		}
	],
	actions(data) {
		const name = "{{name}}";
		const actions = [
			{
				type: "add",
				path: `src/service/${name}/index.js`,
				templateFile: "plop-templates/service/index.hbs",
				data: {
					name,
					group: data.group,
					hasGroup: !!data.group
				}
			}
		];
		return actions;
	}
};
